home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10051 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  47 lines

  1. Path: news-m01.ny.us.ibm.net!usenet
  2. From: mitch@ibm.net
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C code in a C++ app
  5. Date: Wed, 06 Mar 1996 16:52:35 GMT
  6. Organization: NRMA
  7. Message-ID: <4hide6$33ng@news-s01.ny.us.ibm.net>
  8. References: <4h7t43$6as@frodo.smartlink.net>
  9. NNTP-Posting-Host: slip202-135-13-83.sy.au.ibm.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. thomash@warp10.smartlink.net (Thomas Hackbarth) wrote:
  13.  
  14. >I'm working on porting a C app. from MAC to the PC. The app is basicly C 
  15. >and I'm replacing the UI for the PC side. I need to compile and link C 
  16. >code into my MFC application. I get errors basicly saying I can't compile 
  17. >C code with CPP, OK I renamed the file to CPP then I need to add #include 
  18. ><stdafx.h>. I would rather not change any of the C files at all. They 
  19. >need to stay multiplatform as well as multi-compiler. 
  20.  
  21. >Does anyone know how to build a MCF app with C code, with out changing 
  22. >the C code.
  23.  
  24. >Thanks
  25. >Thomas
  26.  
  27. You need to tell the compiler to use the linkage conventions of the
  28. "C" language using the extern declaration specifier.  Eg
  29.  
  30. extern "C" {
  31.  
  32.     // a whole bunch of C functions
  33.     void foo(void)
  34.         {
  35.         .....
  36.         }
  37.  
  38. }    // extern
  39.  
  40. Mitch
  41.  
  42.  
  43. --
  44. Mitch Fielding
  45. mitch@ibm.net
  46.  
  47.